/*     */ package com.zimbra.cs.account.accesscontrol;
/*     */ 
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.cs.account.Account;
/*     */ import com.zimbra.cs.account.DistributionList;
/*     */ import com.zimbra.cs.account.Entry;
/*     */ import com.zimbra.cs.account.Group;
/*     */ import com.zimbra.cs.account.NamedEntry;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashSet;
/*     */ import java.util.List;
/*     */ import java.util.Set;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class GroupACLs
/*     */ {
/*     */   private NamedEntry target;
/*     */   private Set<String> directGroupsOfAccountTarget;
/*  44 */   private Set<ZimbraACE> aclsOnGroupTargetsAllowedNotDelegable = new HashSet();
/*  45 */   private Set<ZimbraACE> aclsOnGroupTargetsAllowedDelegable = new HashSet();
/*  46 */   private Set<ZimbraACE> aclsOnGroupTargetsDenied = new HashSet();
/*     */   
/*     */   GroupACLs(Entry target) throws ServiceException {
/*  49 */     if ((target instanceof Account)) {
/*  50 */       Account acctTarget = (Account)target;
/*  51 */       this.target = acctTarget;
/*  52 */       this.directGroupsOfAccountTarget = Provisioning.getInstance().getDirectDistributionLists(acctTarget);
/*  53 */     } else if ((target instanceof DistributionList)) {
/*  54 */       DistributionList groupTarget = (DistributionList)target;
/*  55 */       this.target = groupTarget;
/*     */     } else {
/*  57 */       throw ServiceException.FAILURE("internal error", null);
/*     */     }
/*     */   }
/*     */   
/*     */   private boolean applies(Group grantedOn, ZimbraACE ace) {
/*  62 */     if (!ace.disinheritSubGroups()) {
/*  63 */       return true;
/*     */     }
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*  69 */     if ((this.target instanceof Account)) {
/*  70 */       return this.directGroupsOfAccountTarget.contains(grantedOn.getId());
/*     */     }
/*     */     
/*  73 */     return this.target.getId().equals(grantedOn.getId());
/*     */   }
/*     */   
/*     */ 
/*     */   void collectACL(Group grantedOn, boolean skipPositiveGrants)
/*     */     throws ServiceException
/*     */   {
/*  80 */     Set<ZimbraACE> allowedNotDelegable = ACLUtil.getAllowedNotDelegableACEs(grantedOn);
/*  81 */     Set<ZimbraACE> allowedDelegable = ACLUtil.getAllowedDelegableACEs(grantedOn);
/*  82 */     Set<ZimbraACE> denied = ACLUtil.getDeniedACEs(grantedOn);
/*     */     
/*  84 */     if ((allowedNotDelegable != null) && (!skipPositiveGrants)) {
/*  85 */       for (ZimbraACE ace : allowedNotDelegable) {
/*  86 */         if (applies(grantedOn, ace)) {
/*  87 */           this.aclsOnGroupTargetsAllowedNotDelegable.add(ace);
/*     */         }
/*     */       }
/*     */     }
/*     */     
/*  92 */     if ((allowedDelegable != null) && (!skipPositiveGrants)) {
/*  93 */       for (ZimbraACE ace : allowedDelegable) {
/*  94 */         if (applies(grantedOn, ace)) {
/*  95 */           this.aclsOnGroupTargetsAllowedDelegable.add(ace);
/*     */         }
/*     */       }
/*     */     }
/*     */     
/* 100 */     if (denied != null) {
/* 101 */       for (ZimbraACE ace : denied) {
/* 102 */         if (applies(grantedOn, ace)) {
/* 103 */           this.aclsOnGroupTargetsDenied.add(ace);
/*     */         }
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   List<ZimbraACE> getAllACLs()
/*     */   {
/* 116 */     if ((!this.aclsOnGroupTargetsAllowedNotDelegable.isEmpty()) || (!this.aclsOnGroupTargetsAllowedDelegable.isEmpty()) || (!this.aclsOnGroupTargetsDenied.isEmpty()))
/*     */     {
/*     */ 
/*     */ 
/* 120 */       List<ZimbraACE> aclsOnGroupTargets = new ArrayList();
/* 121 */       aclsOnGroupTargets.addAll(this.aclsOnGroupTargetsDenied);
/* 122 */       aclsOnGroupTargets.addAll(this.aclsOnGroupTargetsAllowedDelegable);
/* 123 */       aclsOnGroupTargets.addAll(this.aclsOnGroupTargetsAllowedNotDelegable);
/*     */       
/* 125 */       return aclsOnGroupTargets;
/*     */     }
/* 127 */     return null;
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/accesscontrol/GroupACLs.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */